
        <div class="form-group">
            <label class="x100">产品模型:</label>
            <select name="model_id" data-toggle="selectpicker" class="typesel">
                <option value="0" selected>通用类型</option>
                <volist name="model" id="mo">
                <option value="{$mo.id}" <if condition="$mo['id'] eq $va['model_id']">selected</if>>{$mo.name}</option>
                </volist>
            </select>
        </div>
        <!--规格DIV-->
        <div class="form-group norsele">
             
        </div>
        <h4 class="spectitle" style="display: none;">参数列表</h4>
        <!--属性参数DIV-->
        <div class="form-group proattr">

        </div>

<script>
    //回调价格组
    function resultCallGroup(trName, groupprice){
        $(this).dialog('closeCurrent');
        $('#goods_spec_table2 tr').each(function(){
            if( $(this).attr('data-value') == trName ){
                $(this).find('input.gprice').val(groupprice);
            }
        })
    }
    //回调图片
    function resultCallphoto(file, data, ele){
    	data = JSON.parse(data);
   	    if(data[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
   	    	var multimg = ele.parents('.form-group').find('.multimg');
            multimg.append(function() {
		           var odiv = '<div class="pull-left">';
		               odiv += '<img src="'+data.message+'" width="70" />';
		               odiv += '<p class="text-center"><a href="javascript:void(0)" class="remove" data-photo="'+data.message+'">删除</a></p>'
		               odiv += '</div>';
	            return odiv;
	        });
	   	     $('#goods_spec_table2 tr').each(function(){
	             if( $(this).attr('data-value') == data.url ){
	            	 var val = $(this).find('input.gphoto').val();
	            	 if(val){
	            		 var true_val = val+","+data.message;
	            	 }else{
	            		 var true_val = data.message;
	            	 }
	                 $(this).find('input.gphoto').val(true_val);
	             }
	         })
   	    }else{
   	        ele.bjuiajax('ajaxDone', data);
   	    }
    }
    //删除图片
    function delCallphoto(trName,pho){
    	$('#goods_spec_table2 tr').each(function(){
    		 if( $(this).attr('data-value') == trName ){
    			 var val = $(this).find('input.gphoto').val();
    			 var valarray = val.split(","),arr = [];
    			 valarray.forEach(function (item){
   					if( pho != item ){
   						arr.push(item);
   					}
    			 })
    			 $(this).find('input.gphoto').val(arr.join(','));
    		 }
    	})
    }
    $(function () {
        function getnor(vid,goods_id) {
            vid = vid || 0;
            //规格
            $(this).bjuiajax('doLoad', {
                url:"{:U('Goods/nor')}",
                data:{id:vid,'goods_id':goods_id},
                target:$('.norsele')
            });
            //属性
            $(this).bjuiajax('doload', {
                url:'{:U("Goods/tablestwo")}',
                data:{id:vid,'goods_id':goods_id},
                target:$('.proattr')
            });
        }
        $('.typesel').change(function () {
            $('.spectitle').show();
            var vid = this.value;
            getnor(vid);
        });
        getnor({$va['model_id']?$va['model_id']:'0'},{$va['id']?$va['id']:'0'});
//        价格组
        $('.norsele').on('click', 'button.groupprice', function () {
           var v = $(this).parents('tr').attr('data-value'),
               product_id = $(this).parents('tr').attr('data-id'),
               defaultprice = $(this).prev('input').val();
            if( defaultprice && defaultprice > 0 ){
                createDialog("{:U('Forms/member_price')}?vids=" + v+'&default='+defaultprice+'&product_id='+product_id, '价格组设定', 'groups', {width:500, height:400});
            }else{
                $(this).alertmsg('error', '请设置销售价');
            }
        });
//        上传商品规格图片
        $('.norsele').on('click', 'button.photolist',function () {
            var v = $(this).parents('tr').attr('data-value'),
                product_id = $(this).parents('tr').attr('data-id');
            createDialog("{:U('Forms/spec_upload')}?vids="+v+'&product_id='+product_id, '上传商品规格图片', 'spec_upload', {width:800, height:500});
        });
        //删除规格属性
        $("#attr_input_tab").on("click","button.del_attr",function(){
        	$(this).parents('tr').remove();
        })
    });
</script>